//和为 K 的子数组
class Solution {
public:
    int subarraySum(vector<int>& nums, int k) 
    {
        unordered_map<int,int>hash;
        hash[0]=1;
        int sum=0,res=0;
        for(auto e:nums)
        {
            sum+=e;
            if(hash.count(sum-k)!=0)
            {
                res+=hash[sum-k];
            }
            hash[sum]++;
        }
        return res;

    }
};